package xy.come.juhenews.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;

import com.zhy.autolayout.AutoLinearLayout;

import butterknife.BindView;
import butterknife.ButterKnife;
import xy.come.juhenews.Base.BaseActivity;
import xy.come.juhenews.MainActivity;
import xy.come.juhenews.R;
import xy.come.juhenews.Uitils.SPUtils;

/**
 * Created by Xia_焱 on 2018/7/10.
 * e-mail：XiahaotianV@163.com
 */

public class SplashActivity extends BaseActivity {
    @BindView(R.id.ll_splash)
    AutoLinearLayout llSplash;

    @Override
    public int getLayoutId() {
        return R.layout.activity_splash;
    }

    @Override
    protected void initView() {
        alphaAnim();
    }

    @Override
    protected void initData() {

    }

    private void alphaAnim() {
        AlphaAnimation alphaAnimation = new AlphaAnimation(0.7f, 1.0f);
        alphaAnimation.setDuration(1500);
        alphaAnimation.setFillAfter(true);
        alphaAnimation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {

                boolean isFirst = (boolean) SPUtils.get(SplashActivity.this, SPUtils.IsFirst, false);
                if (!isFirst) {
                    SPUtils.put(SplashActivity.this, SPUtils.IsFirst, true);
                    Intent intent = new Intent(SplashActivity.this, GuideActivity.class);
                    startActivity(intent);
                    finish();
                } else {
                    Intent intent = new Intent(SplashActivity.this, MainActivity.class);
                    startActivity(intent);
                    finish();
                }

            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
        llSplash.startAnimation(alphaAnimation);
    }


}
